package com.ifly.service.impl;

import com.ifly.mapper.UserMapper;
import com.ifly.pojo.User;
import com.ifly.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务实现类
 */
@Service
public class UserServiceImpl implements UserService {

    // 注入持久化层 dao层
    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(String name, String pwd) {

        // 从数据库中获取对象
        User user = userMapper.getUserByUsernameAndPwd(name,pwd);

        return user;
    }

    @Override
    public List<User> findAll() {
        List<User>  l= userMapper.searchUser();
        return l;
    }

    @Override
    public int update(User user) {
        return userMapper.update(user);
    }

    @Override
    public int save(User user) {
        return userMapper.save(user);
    }

    @Override
    public int del(Integer id) {
        return userMapper.del(id);
    }
}
